 $.post(
	       url,
	      "send=province",
	      function(data){
	      	for(var i in data){
		      	var id=data[i]['provinceid'];
	        	var val=data[i]['province'];
	        	var option=$("<option></option>").attr("value",id).html(val);
	        	$("#province").append(option);
	               }	      	
	      },
	      "json"
   )

$('#province').change(function(){
	$('#city').html("<option value='0'>请选择</option>");
	$('#area').html('<option value="0">请选择</option>');
	var pid=$(this).val();
	console.log(pid);
	$.post(
	       url,
	      "send=city&id="+pid,
	      function(data){
	      	for(var i in data){
		      	var id=data[i]['cityid'];
	        	var val=data[i]['city'];
	        	console.log(id);
	        	var option=$("<option></option>").attr("value",id).html(val);
	        	$("#city").append(option);
	               }	      	
	      },
	      "json"
   )

})
$('#city').change(function(){
	$('#area').html('<option value="0">请选择</option>');
	var pid=$(this).val();
	$.post(
	       url,
	      "send=area&id="+pid,
	      function(data){
	      	for(var i in data){
		      	var id=data[i]['areaid'];
	        	var val=data[i]['area'];
	        	console.log(id);
	        	var option=$("<option></option>").attr("value",id).html(val);
	        	$("#area").append(option);
	               }	      	
	      },
	      "json"
   )

})


//编辑省设置
 $.post(
	       url,
	      "send=province",
	      function(data){
	      	for(var i in data){
		      	var id=data[i]['provinceid'];
	        	var val=data[i]['province'];
	        	var option=$("<option></option>").attr("value",id).html(val);
	        	$("#province_1").append(option);
	        }	      	
	      },
	      "json"
   )
//编辑里的市设置
$('#province_1').change(function(){
	$('#city_1').html("<option value='0'>请选择</option>");
	$('#area_1').html('<option value="0">请选择</option>');
	var pid=$(this).val();
	console.log(pid);
	$.post(
	       url,
	      "send=city&id="+pid,
	      function(data){
	      	for(var i in data){
		      	var id=data[i]['cityid'];
	        	var val=data[i]['city'];
	        	console.log(id);
	        	var option=$("<option></option>").attr("value",id).html(val);
	        	$("#city_1").append(option);
	               }	      	
	      },
	      "json"
   )

})
$('#city_1').change(function(){
	$('#area_1').html('<option value="0">请选择</option>');
	var pid=$(this).val();
	$.post(
	       url,
	      "send=area&id="+pid,
	      function(data){
	      	for(var i in data){
		      	var id=data[i]['areaid'];
	        	var val=data[i]['area'];
	        	console.log(id);
	        	var option=$("<option></option>").attr("value",id).html(val);
	        	$("#area_1").append(option);
	               }	      	
	      },
	      "json"
   )

})



$('#add_address').click(function(){
	$('.fixed').css({"display":"block"});
})
$('.delete').click(function(){
	$('.fixed').css({"display":"none"});
	$('.fixed_1').css({"display":"none"});
})
$('.edit').click(function(){
	
	val=$(this).attr('hr');
	console.log(val);
	$.post(
         url_1,
         "id="+val,
         function(data){
         	console.log(data[0]);
         	$('#receive_person_1').val(data[0].receive_person);
         	$('#province_1').children('#pro').attr('value',data[0].province_id).html(data[0].province);
         	$('#city_1').children('#cit').attr('value',data[0].city_id).html(data[0].city);
         	$('#area_1').children('#are').attr('value',data[0].area_id).html(data[0].area);
         	$('#detail_1').val(data[0].detail_address);
            $('#receive_mobile_1').val(data[0].receive_mobile);
            $('#hidden').val(data[0].id);            
         },
         "json"
		)
	$('.fixed_1').css({"display":"block"});
})
//增加地址的的form表单不符合要求不能提交
function check(){
	var user     =$('#receive_person').val();
	var province =$('#province').val();
	var city     =$('#city').val();
	var area     =$('#area').val();
	var mobile   =$('#receive_mobile').val();
	var detial   =$('#detial').val();
	var preg=/^1[3|4|5|8][0-9]{9}$/;
	if(user=="" || province==0 || city==0 || area==0 || mobile==""){			
		return false;
	 }else if(!preg.test(mobile)){
		return false;
		console.log("ss")
	 }else{
	 	return true;
	 	console.log("sss")
	 }
}

//编辑地址的的form表单不符合要求不能提交
function check1(){
	var user     =$('#receive_person_1').val();
	var province =$('#province_1').val();
	var city     =$('#city_1').val();
	var area     =$('#area_1').val();
	var mobile   =$('#receive_mobile_1').val();
	var detial   =$('#detail_1').val();
	var preg=/^1[3|4|5|8][0-9]{9}$/;
	if(user=="" || province==0 || city==0 || area==0 || mobile=="" || detial==""){			
		return false;
	 }else if(!preg.test(mobile)){
		return false;
	 }else{
	 	return true;
	 }
}
